package com.jnshu.controller;

import com.jnshu.model.Stu;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/Controller")
public class HelloController {
        private Stu stu;
        public HelloController(){
            this.stu=new Stu();
            stu.setAge(32);
            stu.setId(7007);
            stu.setName("张飞");
            stu.setSex("男");
        }
    @RequestMapping("/hello")
    public String sayHello(Model model){
        model.addAttribute("msg","hello,SpringMVC");
        return "hello";

    }
    @RequestMapping("/json")
    public String jsonDemo(Model model){
            model.addAttribute("stu",this.stu);
            model.addAttribute("code",-2);
            model.addAttribute("message","success");
            return "json";

    }
}
